<template>
	<view :class="currentTheme">
		<a-nabbar name="更多评论" iconName="close" iconSize="30" />
    <view class="content-father">
       <mescroll-body  @init="mescrollInit"  @down="downCallback"  @up="upCallback" :up="upOption" @emptyclick="feedBack">
    <view class="u-padding-32">
			<item-box padding="0" class="content">
				<view >
		      <comment @onFocus="onFocus" :commentsList="dataList" @delete="deleteCommentsId($event)"></comment>
				</view>
			</item-box>
		</view>
     </mescroll-body>
    </view>
		<comment-inputs :focus="focus" @input="getContent($event)" @click="saveComments ($event)" :placeholder="comments.content"></comment-inputs>
	</view>
</template>

<script>
import upCallback from '@/mixins/upCallbackMixin.js'
import commentInputs from '../acomponents/commentInputs.vue';
import comment from '../acomponents/comment.vue';
import { getExhibitComments, saveExhibitComments, delComment } from '@/api/advertising.js';
	export default {
		mixins:[upCallback],
		data() {
			return {
        apiModule:'sns',
				apiType:'exhibitComment',
        name: 'getExhibitComments',
        form: {
          exhibitId:''
        },
				focus:false,
        option: {},
        dataList:[],
        exhibitId:'',
        comments: {
        content: '',
        parentCreater:''
        },
			}
		},
		computed: {
		
		},
		components: {
			comment,commentInputs
		},
		onLoad(option) {
      this.option = option
      this.form.exhibitId = option.exhibitId
      // this.getExhibitComments() // 获取评论
		},
		methods: {
       // 删除评论
   async deleteCommentsId(data){
      console.log(data,'删除的对象');
      await delComment(data)
      this.getExhibitComments()
      this.mescroll.resetUpScroll() // 手动调用mixins组件内刷新的方法
    },
    // 发送评论
    async saveComments(e){
      if(this.comments.parentCreater) {
          await saveExhibitComments({
           exhibitId: this.form.exhibitId,
           content: e,
           parentCreater: this.comments.parentCreater
         })
      } else {
        await saveExhibitComments({
           exhibitId: this.form.exhibitId,
           content: e,
         })
      }
      this.comments = {}
      this.mescroll.resetUpScroll() // 手动调用组件内的方法

    },
    // 获取组件评论
    getContent(e){
      this.comments.content = e
    },
      onFocus(e){
        console.log(e,'穿过');
        this.focus = e
        this.comments.parentCreater = e.creater
        this.comments.content = e.createName

      },
     async getExhibitComments(){
      let res = await getExhibitComments({
         exhibitId: this.option.exhibitId
       })
       this.commentsList = res.content
      }
		},
	}
</script>

<style lang="scss" scoped>
  // .content {
  //   margin-bottom: 150rpx !important;
  // }
   .content-father {
    padding-bottom: 115rpx !important;
  }
</style>
